package com.simulation.web.controller.tech;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.simulation.web.domain.TechFile;
import com.simulation.web.service.ITechFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.simulation.common.annotation.Log;
import com.simulation.common.core.controller.BaseController;
import com.simulation.common.core.domain.AjaxResult;
import com.simulation.common.enums.BusinessType;
import com.simulation.common.utils.poi.ExcelUtil;
import com.simulation.common.core.page.TableDataInfo;

/**
 * 参数配置Controller
 * 
 * @author ruoyi
 * @date 2024-08-31
 */
@RestController
@RequestMapping("/tech/file")
@Api("文件管理")
public class TechFileController extends BaseController {
    @Autowired
    private ITechFileService techFileService;

    /**
     * 查询获取文件列表
     */
//    @PreAuthorize("@ss.hasPermi('tech:file:list')")
    @GetMapping("/list")
    @ApiOperation("获取文件列表-归属自己")
    public TableDataInfo list(TechFile techFile) {
        startPage();
        techFile.setCreateBy(String.valueOf(getLoginUser().getUserId()));
        List<TechFile> list = techFileService.selectTechFileList(techFile);
        return getDataTable(list);
    }


    /**
     * 获取获取文件详情
     */
//    @PreAuthorize("@ss.hasPermi('tech:file:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取文件详情")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(techFileService.selectTechFileById(id));
    }

    /**
     * 新增参数配置
     */
//    @PreAuthorize("@ss.hasPermi('tech:file:add')")
    @Log(title = "新增文件", businessType = BusinessType.INSERT)
    @ApiOperation("新增文件")
    @PostMapping
    public AjaxResult add(@RequestBody TechFile techFile)
    {
        return toAjax(techFileService.insertTechFile(techFile));
    }

    /**
     * 修改参数配置
     */
//    @PreAuthorize("@ss.hasPermi('tech:file:edit')")
    @Log(title = "修改文件详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TechFile techFile)
    {
        return toAjax(techFileService.updateTechFile(techFile));
    }

    /**
     * 删除参数配置
     */
//    @PreAuthorize("@ss.hasPermi('tech:file:remove')")
    @Log(title = "参数配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除文件")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(techFileService.deleteTechFileByIds(ids));
    }
}
